﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Xml;
using System.Xml.Serialization;

using Twilio.TwilML.BaseTypes;

namespace Twilio.TwilML
{
    public class Sms : ResponseVerb
    {
        [XmlAttribute("to")]
        [DefaultValue(null)]
        public string To { get; set; }

        [XmlAttribute("from")]
        [DefaultValue(null)]
        public string From { get; set; }

        [XmlAttribute("action")]
        [DefaultValue(null)]
        public string Action { get; set; }

        [XmlAttribute("method")]
        [DefaultValue(HttpMethod.Post)]
        public HttpMethod Method { get; set; }

        [XmlAttribute("statusCallback")]
        [DefaultValue(null)]
        public string StatusCallback { get; set; }

        private string _Message;
        [XmlText]
        public string Message
        {
            get { return _Message; }
            set
            {
                if (value != null && value.Length >= 160) throw new ArgumentOutOfRangeException("Message", "Message must be less than 160 characters");
                else _Message = value;
            }
        }

        public Sms() { }
        public Sms(string message)
        {
            Message = message;
        }
    }
}
